/**
 * @see [description](https://docs.alipay.com/mini/api/ui-feedback)
 * @example show_toast('操作成功','success',3000);
 */

export default function show_toast(content?: string, type?: 'success' | 'fail' | 'exception' | 'none', duration?: number) {
	const options = {};
	if (content !== undefined) {
		Object.assign(options, {
			content
		});
	}
	if (type !== undefined) {
		Object.assign(options, {
			type
		});
	}
	if (duration !== undefined) {
		Object.assign(options, {
			duration
		});
	}


	return new Promise<boolean>((resolve, _reject) => {
		my.showToast({
			...options,
			success() {
				resolve(true);	// 提示消失
			}
		});
	});
}
